package leetcode.easy;

import leetcode.base.TreeNode;

/**
 * ClassName: $112_HasPathSum
 * Description:
 * date: 2021-11-18 22:34
 *
 * @author liyifan
 */
public class $112_HasPathSum {
    public boolean hasPathSum(TreeNode root, int targetSum) {
        if (root == null)
            return false;
        if (root.left == null && root.right == null)
            return targetSum == root.val;
        return hasPathSum(root.left, targetSum - root.val) || hasPathSum(root.right, targetSum - root.val);
    }
}
